Skip to content

PMM-14858 Skip built-in ClickHouse scrape for external instances#5369

Open
4nte wants to merge 6 commits into
v3from
PMM-14858-fix-external-clickhouse-scrape
Open

PMM-14858 Skip built-in ClickHouse scrape for external instances#5369
4nte wants to merge 6 commits into
v3from
PMM-14858-fix-external-clickhouse-scrape

Conversation

@4nte
Copy link
Copy Markdown

@4nte 4nte commented May 15, 2026

PMM-14858

Feature build

PMM kept scraping 127.0.0.1:9363 even when an external ClickHouse was configured or PMM_DISABLE_BUILTIN_CLICKHOUSE was set.

Introduced new ClickHouseParams model struct that validates and facilitates CH parameters.

ClickHouse scraping is skipped when any of the following are true:

  1. ExternalVM is on. (old behavior)
  2. PMM_DISABLE_BUILTIN_CLICKHOUSE is set. (new)
  3. PMM_CLICKHOUSE_ADDR points to an external host. (new)

Addditionally, we log a warning when PMM_DISABLE_BUILTIN_CLICKHOUSE is not set and PMM_CLICKHOUSE_ADDR is an external address (not 127.0.0.1) to warn user about unwanted drift in their configuration.

@4nte 4nte requested a review from a team as a code owner May 15, 2026 12:23
@4nte 4nte requested review from JiriCtvrtka and maxkondr and removed request for a team May 15, 2026 12:23
Comment thread managed/models/clickhouse_params.go
Comment thread managed/services/victoriametrics/victoriametrics.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 77.41935% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.25%. Comparing base (6ecb7d5) to head (d6f828a).
⚠️ Report is 3 commits behind head on v3.

Files with missing lines Patch % Lines
managed/cmd/pmm-managed/main.go 0.00% 13 Missing ⚠️
managed/services/victoriametrics/prometheus.go 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #5369      +/-   ##
==========================================
+ Coverage   43.18%   43.25%   +0.07%     
==========================================
  Files         413      413              
  Lines       42253    42258       +5     
==========================================
+ Hits        18247    18280      +33     
+ Misses      22140    22112      -28     
  Partials     1866     1866              
Flag Coverage Δ
managed 42.40% <77.41%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 15, 2026

CLA assistant check
All committers have signed the CLA.

clickhouseAddrF := kingpin.Flag("clickhouse-addr", "Clickhouse database address").Default("127.0.0.1:9000").Envar("PMM_CLICKHOUSE_ADDR").String()
clickhouseUsernameF := kingpin.Flag("clickhouse-username", "Clickhouse database user").Default("default").Envar("PMM_CLICKHOUSE_USER").String()
clickhousePasswordF := kingpin.Flag("clickhouse-password", "Clickhouse database user password").Default("clickhouse").Envar("PMM_CLICKHOUSE_PASSWORD").String()
clickhouseBuiltinDisabledF := kingpin.Flag("clickhouse-disable-builtin", "Disable the built-in ClickHouse").Envar("PMM_DISABLE_BUILTIN_CLICKHOUSE").Bool()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any benefit from this additional var. The fact of set PMM_CLICKHOUSE_ADDR looks enough that external CH usage is requested.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering following options:

  1. Check if PMM_CLICKHOUSE_ADDR hostname is not 127.0.0.1
  2. Check if PMM_DISABLE_BUILTIN_CLICKHOUSE is set
  3. Check both 1. and 2.

I agree PMM_CLICKHOUSE_ADDR is sufficient to determine this and would prefer it too. My concern is that PMM_DISABLE_BUILTIN_CLICKHOUSE is already explicitly documented as the flag that disables internal CH and managed-init already relies on it.
Not checking it here, while checking it in managed-init seemed inconsistent, unless we treat PMM_DISABLE_BUILTIN_CLICKHOUSE as an env var that is exclusive to managed-init.

Having all that said, do you still think we should just infer from PMM_CLICKHOUSE_ADDR and not lookup PMM_DISABLE_BUILTIN_CLICKHOUSE?

Copy link
Copy Markdown
Member

@ademidoff ademidoff May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed to deprecate all PMM_DISABLE_BUILTIN_ env variables, since their use conflicts with PMM_<TECH>_ADDR variables, which should be the only source of truth. Therefore, this fix will rely on PMM_CLICKHOUSE_ADDR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also discussed this with @ademidoff, we all agree PMM_CLICKHOUSE_ADDR is technically sufficient to determine whether CH is internal or external.

I will omit PMM_DISABLE_BUILTIN_CLICKHOUSE and rely on PMM_CLICKHOUSE_ADDR as a single source of truth.

Since PMM_DISABLE_BUILTIN_CLICKHOUSE is obviously redundant and creates ambiguity, I will create a separate issue to deprecate PMM_DISABLE_BUILTIN_CLICKHOUSE in favor of inferring from PMM_CLICKHOUSE_ADDR

Comment thread managed/models/clickhouse_params.go Outdated
Co-authored-by: Maxim Kondratenko <maxim.kondratenko@percona.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants